﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace SBPweb.Messenger.ClientApplication.Controls
{
    public partial class Credentials : UserControl, IPopupDialogContentControl
    {

        #region Private fields

        private Dictionary<string, object> values = new Dictionary<string, object>();

        #endregion

        #region Constructor logic

        public Credentials()
        {
            InitializeComponent();
            Values["UserName"] = tbUserName.Text;
            Values["Password"] = pbPassword.Password;
        }

        #endregion

        #region Property accessors

        public bool IsCloseable
        {
            get
            {
                return !string.IsNullOrEmpty(tbUserName.Text);
            }
        }

        public Dictionary<string, object> Values
        {
            get
            {
                return values;
            }
        }

        #endregion

        #region Event handlers

        private void pbPassword_PasswordChanged(object sender, RoutedEventArgs e)
        {
            Values["Password"] = pbPassword.Password;
        }

        private void tbUserName_TextChanged(object sender, TextChangedEventArgs e)
        {
            Values["UserName"] = tbUserName.Text;
        }

        #endregion
    }

}
